package com.duty.UI;

import com.duty.UI.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class MenuActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.menu);
        
        ListView menuList = (ListView) findViewById(R.id.ListView_Menu);
        String[] items = { getResources().getString(R.string.menu_item_duty),
                getResources().getString(R.string.menu_item_info),
                getResources().getString(R.string.menu_item_about),
                getResources().getString(R.string.menu_item_updates)};
        ArrayAdapter<String> adapt = new ArrayAdapter<String>(this, R.layout.menu_item, items);
        menuList.setAdapter(adapt);      
        menuList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
        	public void onItemClick(AdapterView<?> parent, View itemClicked, int position, long id) {
                // Note: if the list was built "by hand" the id could be used.
                // As-is, though, each item has the same id
                TextView textView = (TextView) itemClicked;
                String strText = textView.getText().toString();
                if (strText.equalsIgnoreCase(getResources().getString(R.string.menu_item_duty))) {
                    // Launch the Province Activity
                    startActivity(new Intent(MenuActivity.this, SelectProvinceActivity.class));
                  //  MenuActivity.this.finish();
                } else if (strText.equalsIgnoreCase(getResources().getString(R.string.menu_item_info))) {
                    // Launch Info Activity
                    startActivity(new Intent(MenuActivity.this, InfoActivity.class));        
                }
                  else if (strText.equalsIgnoreCase(getResources().getString(R.string.menu_item_about))) {
                    // Launch About Activity
                    startActivity(new Intent(MenuActivity.this, AboutActivity.class));        
                }
                  else if (strText.equalsIgnoreCase(getResources().getString(R.string.menu_item_updates))) {
                    // Launch Updates Activity
                    startActivity(new Intent(MenuActivity.this, UpdateActivity.class));        
                }
            }
        });
        
    }
    
}